import urllib.request
import os
# import urllib2
# import requests


import requests


def schedule(a, b, c):
    '''''
    a:已经下载的数据块
    b:数据块的大小
    c:远程文件的大小
   '''
    per = 100.0 * a * b / c
    if per > 100:
        per = 100
    print('%.2f%%' % per)


def dowlonad():
    '地址必须准确，不会自动将http重定向https'
    url = 'https://1-197-214-26.d.123pan.cn:30443/123-156/1cb00065/1626513-0/1cb00065db9b215fecabfabb511df89c?v=3&t=1648893295&s=6fdcefded7a36b026ce0b734d74ca0c1&i=da4d6e20&filename=WinDynamicDesktop_5.0.0_Setup.zip&d=37d1c17f'
    local = os.path.join('E:/', 'WinDynamicDesktop_5.0.0_Setup.zip')
    urllib.request.urlretrieve(url, local, schedule)


if __name__ == '__main__':
    dowlonad()
